<template>
	<view class="contain2">
		<view class="company">{{company.name}}</view>
		<input type="text" v-model="comData.infoNo">
		<uni-data-select class="sel" :localdata="comType" v-model="comData.questionType"></uni-data-select>
		<textarea v-model="comData.description" cols="30" rows="10"></textarea>
		<button type="primary"  @tap="click">提交</button>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from "@dcloudio/uni-app"
	const comData = ref({
		companyId: "",
		infoNo: "",
		questionType: "",
		description: ""
	})
	let infoNo = ""
	onLoad((params) => {
		infoNo = params.id
		getComType()
		getInfo(infoNo)
		uni.setNavigationBarTitle({
			title:"快递投诉"
		})
	})

	const comType = ref([])
	// 获取投诉类型
	async function getComType() {
		let {
			data
		} = await uni.$get("/prod-api/system/dict/data/type/li-complaint-question-type")
		data.forEach(item => {
			comType.value.push({
				text: item.dictLabel,
				value: item.dictValue
			})
		})
		console.log(comType.value);

	}

	const company = ref({})

	async function getInfo(id) {
		let {
			data
		} = await uni.$get("/prod-api/api/logistics-inquiry/logistics_info/" + id)
		// info.value = res.data
		// info.value.company.imgUrl = uni.$base_url + info.value.company.imgUrl
		// console.log(info.value);
		company.value = data.company
		comData.value.companyId = data.company.id
		comData.value.infoNo = id


	}
	async function click()
	{
		console.log(comData.value);
		 let res=await uni.$post("/prod-api/api/logistics-inquiry/logistics_complaint",comData.value)
		 console.log(res);
		 uni.navigateBack()
	}
	
</script>

<style lang="scss" scoped>
	.contain2{
		margin: 15px;
		font-size: 25rpx;
		.company{
			height: 50rpx;
		}
		input{
			border:1px solid #ccc;
			height: 70rpx;
			border-radius: 5px;
			margin-top: 10px;
			font-size: 25rpx;
			padding-left: 5px;
		}
		.sel{
			margin-top: 10px;
		}
		textarea{
			border:1px solid #ccc;
			margin-top: 10px;
			width: 100%;
		}
		button{
			margin-top: 10px;
		}
	}

</style>